<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设置我的资料</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <script type="text/javascript" charset="utf-8" src="${global_templets_skin}/ueditor/ueditor.html.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="${global_templets_skin}/ueditor/ueditor.all.js"> </script>
    <script type="text/javascript" charset="utf-8" src="${global_templets_skin}/ueditor/lang/zh-cn/zh-cn.js"></script>
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${global_templets_skin}/systemstyle/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">添加模板详细页面</div>
                <div class="layui-card-body">

                    <form class="layui-form" lay-filter="" pad15>
                        <div class="layui-form-item">
                            <label class="layui-form-label">所属模型</label>
                            <div class="layui-input-inline">
                                <select name="moduleId" lay-filter="moduleId" lay-verify="required" lay-search="">
                                    <option value="">请选择该栏目使用的模型</option>
                                    <#list modulelist as list>
                                    <option value="${list.id!}">${list.moduleName!}</option>
                                    </#list>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">不可修改。一般用于后台登入名</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板类型</label>
                            <div class="layui-input-inline">
                                <select name="pageType" lay-filter="pageType" lay-verify="required" lay-search="">
                                    <option value="">请选择该模板类型</option>
                                    <option value="1">频道封面模板</option>
                                    <option value="2">列表模板</option>
                                    <option value="3">内容页面模板</option>
                                    <option value="4">单独页面模板</option>
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">模板类型，比如：频道首页模板或者内容页面模板</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="templateName" value="" lay-verify="required" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">模板编辑</label>
                            <div class="layui-input-block">
                                <script name="templatePage" id="templatePage" type="text/plain"></script>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">模板说明</label>
                            <div class="layui-input-inline">
                                <input type="text" name="remark" value="" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <input type="hidden" name="templateId" id="templateId" value="${templateId!}">
                                <button class="layui-btn" lay-submit lay-filter="setTemplatePage">确认修改</button>
                                <button type="reset" class="layui-btn layui-btn-primary reset">重新填写</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var ue = UE.getEditor('templatePage');
    ue.ready(function() {
        ue.setContent('');
        ue.setHeight(400);
    });
</script>
<script src="${global_templets_skin}/systemstyle/layui/layui.js"></script>
<script>
    layui.config({
        base: '${global_templets_skin}/systemstyle/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'set','form'], function () {
        var form   = layui.form;
        var $      = layui.jquery;
        var layer  = layui.layer;

        form.on('submit(setTemplatePage)', function(data) {
            if (ue.getContent() == "" || ue.getContent().length() < 20 ) {
                layer.msg("模板内容不得为空或者小于20个字符", {icon: 2});
                return false;
            }
            data.field.templatePage=ue.getContent();
            $.ajax({
                url:'/admin/template/page/add.do',
                type:'post',
                dataType: 'json',
                data: data.field,
                success:function(e){
                    if (e.code == "0") {
                        layer.msg('成功');
                        window.location.reload();
                    }else {
                        layer.msg(e.message, {icon: 2});
                    }
                }
            })
            //防止页面跳转
            return false;
        });
        $(document).on('click','.reset',function(){
            //文本框获取焦点时清空默认显示的内容
            ue.setContent('');
        });
    });
</script>

</body>
</html>